<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'tagsDemo.jsp' starting page</title>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    	使用Struts2标签接收双向绑定的数据如下:<br/>
    	<s:property value="msg"/><br/>
    	<s:property value="dept.deptno"/>-----<s:property value="dept.dname"/>
    	<hr/>
    	接收request属性范围内的数据:<br/>
    	<s:property value="#request.info"/><br/>
    	<s:property value="#request.deptvo.deptno"/>===============<s:property value="#request.deptvo.dname"/><br/>
    	接收到的日期为:<br/>
    	<s:date name="#request.mydate" format="yyyy-MM-dd HH:mm:ss.SSS" />
    	<hr/>
    	读取后台配置文件的值，并且可以植入占位符中的数值:<br/>
		<s:i18n name="Message">
			<s:text name="news.msg">
				<s:param >Java1</s:param>
				<s:param >Java2</s:param>
				<s:param >Java3</s:param>
				<s:param >Java4</s:param>
				<s:param >Java5</s:param>
			</s:text>
		</s:i18n>
		<s:i18n name="Page">
			<s:text name="news.add.page"></s:text>
		</s:i18n>
		<hr/>
		读取后台传来的部门集合:<br/>
		<s:if test="#request.depts != null "> <!-- 这里可以写表达式!=null -->
			<s:iterator value="#request.depts" >
				<s:property value="deptno"/>
				<s:property value="dname"/>
				<br/>
			</s:iterator>
		</s:if>
		<br/>
		使用EL表达式读取后台传来的部门集合:<br/>
		<s:if test="#request.depts != null">
			<s:iterator value="#request.depts" var="temp_dept">
				${temp_dept.deptno }&nbsp;${temp_dept.dname }
				<br/>
			</s:iterator>
		</s:if>
		<br/>
		<hr/>
		使用struts标签定义表单:<br/>
		<s:form action="xxx.action" method="post">
			<s:textfield key="username" value="用户名"></s:textfield>
			<s:submit value="提交"></s:submit>
		</s:form>
		<br/>
		使用struts标签定义表单，这次去除样式简单化 :<br/>
		<s:form action="xxx.action" method="post" theme="simple">
			<s:textfield key="username" value="用户名"></s:textfield>
			<s:submit value="提交"></s:submit>
		</s:form>
		<hr/>
		测试Struts2标签生成的下拉列表框:
		<s:if test="#request.depts != null ">
			<s:select list="#request.depts" id="mydepts" name="mydepts"  listKey="deptno" listValue="dname" >
			</s:select>
		</s:if>
		<br/>
		测试Struts2标签生成的复选框:
		<s:form action="chkdemo.action" method="post">
			<s:if test="#request.depts != null">
				<s:checkboxlist name="chk" id="chk" list="#request.depts" listKey="deptno" listValue="dname" ></s:checkboxlist>		
			</s:if>
			<s:submit value="提交"></s:submit>
		</s:form>

		
  </body>
</html>
